import { param2Obj } from "@/utils";

const userMap = {
  admin: {
    role: ["admin"],
    token: "admin",
    introduction: "超级管理员",
    name: "Super Admin"
  },
  normal: {
    role: ["normal"],
    token: "normal",
    introduction: "普通用户",
    name: "Normal User"
  }
}

export default {
  loginByUsername: config => {
    const { username } = JSON.parse(config.body);
    return userMap[username];
  },
  getUserInfo: config => {
    const { token } = param2Obj(config.url);
    if (userMap[token]) {
      return userMap[token];
    } else {
      return false;
    }
  },
  logout: () => "success"
};
